Repository navigation
feat(server): graceful shutdown - #120
Closed
TimeExceed wants to merge 2 commits into
Closed
TimeExceed wants to merge 2 commits into
TimeExceed wants to merge 2 commits into
Conversation
Owner
|
@TimeExceed Thanks for the PR. Please reformat the code and update PR. |
3 tasks done
gbaranski
added a commit
that referenced
this pull request
May 18, 2026
Adds `Server::graceful_shutdown` that actually drains the server before exiting, replacing the loop-break-only behavior proposed in #120. Semantics: - New connections delivered after shutdown begins are rejected with a Close(Away) frame instead of being left to hang on an undrained queue. - Queued `Server::call` messages are dropped (no `on_call` after shutdown). - Every live session is sent a Close(Away, "server shutting down") frame via a per-session watch::Receiver task; the actor then awaits the natural close path so `on_disconnect` fires for every session. - The future resolves only after all sessions have drained, and the server-actor task returned by `Server::create` exits at the same time. - Concurrent callers are all acknowledged; calls after the actor has exited return `GracefulShutdownError::ServerStopped`. Tests cover: full drain of live sessions with CloseCode::Away delivered to `on_disconnect`, immediate completion when no sessions exist, and idempotency across concurrent callers plus the post-exit error case. The `examples/echo-server-graceful-shutdown` example shows the intended shutdown sequence: abort the TCP acceptor, await `graceful_shutdown`, await the server task. Supersedes #120. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.